#!/usr/bin/ruby

require 'yaml'
require 'net/http'
require 'uri'

target   = YAML.load_file( 'target' )
form_url = URI.parse( target["url"] )
request  = Net::HTTP::Post.new( form_url.path )
request.set_form_data( target["form"]["fields"] )
response = Net::HTTP.new( form_url.host, form_url.port ).start { |http|
  http.request( request )
}

case response
when Net::HTTPSuccess, Net::HTTPRedirection
  puts response.body
else
  response.error!
end

